﻿using ReflectionStudio.Core.Events;
using System;
using System.Data;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Media;
using System.Diagnostics;
using System.ComponentModel;
using WPFExcelReport.Helpers;
using System.Windows.Input;
namespace WPFExcelReport
{
    public partial class TWS31
    {
        public TWS31()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            MV = new VWASTKE();
            this.DataContext = MV;
            InitializeComponent();
        }
        public override void OnWARPChg()
        {
            if (!IsEdit)
                return;
            if (dwMaster == null)
                return;
            if (WARP.Length < 32)
                return;
            TMV.WAKKART = WARP.Substring(1, 20);
            TMV.WAKKVAR = WARP.Substring(21, 2);
            TMV.WAKKFARBE = WARP.Substring(23, 10);
            base.OnWARPChg();
        }
        //用于从VA10导出
        public override void OnEXAUFChg(string vlaue)
        {
            TBMain.Clear();
            if (EXAUF.Length < 34)
                return;
            base.OnEXAUFChg(vlaue);
            dwData = TBMain.NewRow();
            dwData["WAKMANDANT"] = app.Mandant;
            dwData["WAKART"] = EXAUF.Substring(1, 20);
            dwData["WAKVAR"] = EXAUF.Substring(21, 2);
            dwData["WAKWCOL"] = EXAUF.Substring(24, 10);
            SResult =TMV.QWAK01(dwData); 
            if (SResult.Tables[0].Rows.Count > 0)
            {
                MergeData(SResult, true);
                return;
            } 
            if (!IsAuto)
                return;
          
            PM["ART"] = EXAUF.Substring(1, 20);
            PM["VAR"] = EXAUF.Substring(21, 2);
            PM["FARBE"] = EXAUF.Substring(24, 10);
            TMV.CREATEBYWF(PM);
            vwMaster.View.MoveCurrentToFirst();
        } 
    }
}
